﻿jQuery.myjs = function () { };

(function ($) {
    $.extend($.myjs, {
        changeCustom: function (code) {
            $.post("/custom/ChangeCurrentCustomCode", "customcode=" + code)
			.success(function (result) {
			    if (result.status == "success") {
			        window.location.href = "/roomdata/index1";
			    }
			    else {
			        alert(result.msg);
			    }
			})
			.error(function (result) {
			    alert(result.statusText);
			})
        },
        ajax: function (url, elementId, successMethod) {
            $.ajax({
                url: url,
                type: "POST",
                data: $("#" + elementId + ' *').serialize(),
                cache: false,
                async: true,
                dataType: 'json',
                timeout: 100000,
                error: function (request, settings) {
                    alert(request.responseText);
                },
                beforeSend: function (reques) {
                    reques.setRequestHeader('isAjax', 'true');
                },
                success: function (result) {
                    if (result == null) {
                        return;
                    }

                    if (result.status == "error") {
                        alert(result.msg);
                        return;
                    }
                    alert(result.msg);
                    if (successMethod != undefined) {
                        successMethod();
                    }
                }
            });
        }
    });
})(jQuery);